package socket;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * Created by zzy on 2018/1/9.
 */
public class SocketServerOne {


    public static void main(String[] args) {
        try {
            //1、创建一个服务端socket，即ServerScoket,指定绑定端口，并监听此端口
            ServerSocket serverSocket=new ServerSocket(9999);
            //2、调用accept()方法监听,等待客户端连接
            Print.print("-------服务器即将启动，等待客户端链接——————");
            int count=0;
            while (true){
                Socket socket=serverSocket.accept();
                count++;
                Print.print("当前连接数："+count);
                (new ServerThread(socket)).start();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
